
import os
import pickle

class Configuration( object ):
    """"""

    def __init__( self ):

        print "Configuration initializing"

        self._storeLocation = self._storeLocation or ""

    def storeConfiguration( self, name, info ):
        """
        DOCSTRING
        """

        storeConfigName = os.path.join( self._storeLocation, "%s.config" % name ) # pylint: disable-msg=E1101

        try:
            with open( storeConfigName, "wb" ) as configFile:
                pickle.dump( info, configFile )

            return True

        except IOError:
            if os.path.exists( storeConfigName ):
                os.remove( storeConfigName )

            return False

    def retrieveConfiguration( self, name ):
        """
        DOCSTRING
        """

        storeConfigName = os.path.join( self._storeLocation, "%s.config" % name ) # pylint: disable-msg=E1101

        try:
            with open( storeConfigName, "rb" ) as configFile:
                info = pickle.load( configFile )

            return info

        except IOError:
            return None
